package com.diqye.engine.interceptor;

import java.lang.reflect.Method;


import com.diqye.engine.Controller;

public abstract class Interceptor {

	public Interceptor next;
	
	/**
	 * 判断路由 是否是需要拦截的路由
	 * @return
	 */
	public abstract boolean validateAction(String reqAction);
	
	public final void intercept(String action,Controller controller,Method method)throws Exception{
		if(validateAction(action)){
			intercept(action,controller,method,this);
		}else{
			next.intercept(action,controller,method);
		}
	}
	
	protected abstract void intercept(String action,Controller controller,Method method,Interceptor last) throws Exception;
	
}
